package com.qdlc.p2p.dal.model;

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.qdlc.p2p.common.constant.BorrowStatus;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.BeanUtils;

import com.google.gson.annotations.Expose;
import com.qdlc.p2p.common.constant.BorrowStyle;
import com.qdlc.p2p.common.constant.BorrowType;
import com.qdlc.p2p.common.constant.UserType;
import com.qdlc.p2p.common.exception.BorrowException;
import com.qdlc.p2p.common.exception.BusinessException;
import com.qdlc.p2p.common.exception.UserException;
import com.qdlc.p2p.common.util.DateUtil;
import com.qdlc.p2p.common.util.Page;
import com.qdlc.p2p.common.util.StringUtil;
import com.qdlc.p2p.common.util.ValidateUtil;
import com.qdlc.p2p.common.util.code.MD5;
import com.qdlc.p2p.dal.checkrule.AutoTenderConfRuleCheck;
import com.qdlc.p2p.dal.common.RuleCheckHelper;
import com.qdlc.p2p.dal.dto.Borrow;
import com.qdlc.p2p.dal.dto.BorrowMortgage;
import com.qdlc.p2p.dal.dto.BorrowUpload;
import com.qdlc.p2p.dal.dto.User;
import com.qdlc.p2p.dal.dto.UserCache;
import com.qdlc.p2p.dal.dto.UserIdentify;
import com.qdlc.p2p.dal.model.interest.InstallmentRepaymentCalculator;
import com.qdlc.p2p.dal.model.interest.InterestCalculator;
import com.qdlc.p2p.dal.model.interest.MonthlyInterestCalculator;
import com.qdlc.p2p.dal.model.interest.OnetimeRepaymentCalculator;
import com.qdlc.p2p.dal.util.UserUtils;

public class BorrowModel extends Borrow implements Serializable {

    /** 借款期限 */
    @Expose
    private String timeLimitTip;

    /** 当前页码 */
    private int page = 1;

    /** 每页数据条数 */
    private int rows = Page.ROWS;

    /** 用户ID */
    @Expose
    private long userId;

    /** 担保公司ID */
    @Expose
    private long vouchFirmId;

    /** 标名 */
    @Expose
    private String borrowName;

    /** 用户名 */
    @Expose
    private String userName;

    /** 实名 */
    @Expose
    private String realName;

    /** 投标金额 */
    @Expose
    private double money;

    /** 交易密码 */
    @Expose
    private String payPwd;

    /** 最近还款时间 */
    @Expose
    private String minRepaymentTime;

    /** 还款 */
    @Expose
    private long repaymentId;

    /** 申请信用额度 */
    @Expose
    private int amount;

    /** 备注 */
    @Expose
    private String remark;

    /** 我要投资 - 利率排序 */
    @Expose
    private int aprSearch;

    /** 我要投资 - 期限排序 */
    @Expose
    private int timeSearch;

    /** 我要投资 - 借款金额排序 */
    @Expose
    private int moneySearch;

    /** 我要投资 - 信用等级排序 */
    @Expose
    private int creditSearch;

    /** 我要投资 - 升、降排序 */
    @Expose
    private int order;

    /** 开始时间 */
    @Expose
    private String startTime;

    /** 结束时间 */
    @Expose
    private String endTime;

    /** 日期范围：0：全部，1：最近七天 2：最近一个月 3：最近两个月，4 最近三个月 */
    @Expose
    private int time;

    /** 还款传参使用借款ID */
    @Expose
    private long borrowId = 0;

    /** 是否为定向标 */
    @Expose
    private int isDXB;

    /** 是否为定时 */
    @Expose
    private int isDS;

    /** 借款标名隐藏后 */
    @Expose
    private String borrowNameHide;

    /** 用户第三方用户号 */
    @Expose
    private String tppUserCustId;

    @Expose
    private String bidStatus;

    /** 投标时候的订单号 */
    @Expose
    private String tenderBilNo;

    /** 投标时间 */
    @Expose
    private String tenderBilDate;

    /** 环讯返回状态码 */
    @Expose
    private String errMsg;

    /** 车型抵押 */
    private List<BorrowMortgage> borrowMortgageList;

    /** 正在借款项目信息 */
    @Expose
    private int count;

    @Expose
    private double borrowTotal;

    /** 是否显示重新登记按钮 */
    @Expose
    private int isShowRegister;

    /** 当前需要还的期数 */
    @Expose
    private int currPeriod;

    /** 查询条件（借款人，邮箱地址，公司名称） */
    @Expose
    private String searchName;

    /** 更新前标的状态 */
    @Expose
    private int preStatus;

    /** 定向密码 */
    @Expose
    private String inPwd;

    /** 红包id字符串 */
    @Expose
    private String redEnvelopeStr;

    /** 红包id */
    @Expose
    private long[] redEnvelopeIds;

    /** 红包金额 */
    @Expose
    private double totalRedEnvelopeMoney;

    /** 体验券id */
    @Expose
    private long[] experiences;

    /** 体验金 */
    @Expose
    private double totalExperienceMoney;

    /** 是否开启体验券投资 0：未开启，1：开启 */
    @Expose
    private byte openExperience;

    /** 体验券投标最大额度 */
    @Expose
    private double mostExperience;

    /** 单人体验券投标最大额度 */
    @Expose
    private double mostExperienceSingle;

    /** 是否环讯接口 */
    @Expose
    private boolean ips;

    private Integer[] categorys;

    private Integer[] types;

    private Integer[] statuss;

    @Expose
    private Long[] myRIRCouponId;

    /** 加息券id */
    @Expose
    private long rateInterestId;

    /** 设置投标标记 */
    @Expose
    private String tenderResultFlg;
    
    /** 投标类型 0网站投标;1自动投标;2手机投标 */
    private byte tenderType;

    /**
     * 标的期限
     *
     * @return
     */
    public String getTimeLimitTip() {
        if (getType() == 101) {
            return "满标即还";
        } else if (getBorrowTimeType() == 1) {
            return getTimeLimit() + "天";
        } else if (getBorrowTimeType() == 0) {
            return getTimeLimit() + "个月";
        }
        return timeLimitTip;
    }

    /**
     * 是否显示推荐标
     */
    private int check;

    public int getCheck() {
        return check;
    }

    public void setCheck(int check) {
        this.check = check;
    }

    /**
     * 缩略图地址
     *
     * @param timeLimitTip
     */
    private String picurl;
    /**
     * 参数
     *
     * @return
     */
    private String param;

    public String getPicurl() {
        return picurl;
    }

    public void setPicurl(String picurl) {
        this.picurl = picurl;
    }

    public void setTimeLimitTip(String timeLimitTip) {
        this.timeLimitTip = timeLimitTip;
    }


    public String getBorrowNameHide() {
        if (StringUtil.isNotBlank(getName()) && getName().length() > 7) {
            this.borrowNameHide = getName().substring(0, 6) + "***";
        }
        return borrowNameHide;
    }

    public void setBorrowNameHide(String borrowNameHide) {
        this.borrowNameHide = borrowNameHide;
    }

    public static BorrowModel instance(Borrow borrow) {
        BorrowModel borrowModel = new BorrowModel();
        BeanUtils.copyProperties(borrow, borrowModel);
        return borrowModel;
    }

    public Borrow prototype() {
        Borrow borrow = new Borrow();
        BeanUtils.copyProperties(this, borrow);
        return borrow;
    }

    public static BorrowModel instanceCurr(Borrow borrow,
                                           BorrowModel borrowModel) {
        BeanUtils.copyProperties(borrow, borrowModel);
        return borrowModel;
    }

    /**
     * 校验借款人 实名状况
     *
     * @param userIdentify
     */
    public static void checkBorrowUser(UserIdentify userIdentify) {
    	String tppUserCustId = UserUtils.getUserTppCustId(userIdentify.getUserId());
        if (StringUtils.isBlank(tppUserCustId)) {
            throw new BorrowException("发标前请开通第三方支付账户！", "/member/security/setting.html", "前往开通《《《");
        }
    }

    /**
     * 发标校验验证码
     *
     * @param imgCode
     */
    public void validBorrowCode(String imgCode) {
        if (!ValidateUtil.checkValidCode(imgCode)) {
            throw new UserException("验证码不正确！", 1);
        }
    }

    /**
     * 发标 校验还款方式
     */
    public void validBorrowStyle() {
        if (getStyle() == 0) {
            throw new BorrowException("请选择还款方式！", 1);
        }
        if (getAccount() % 1.0 != 0) {
            throw new BorrowException("借款总金额必须为整数！", 1);
        }
        if (StringUtil.isBlank(getName())) {
            throw new BorrowException("标题不能为空！", 1);
        }

        int[] styleArr = null;
        if (getType() == BorrowType.TYPE_SECOND
                && getStyle() != BorrowStyle.STYLE_ONETIME_REPAYMENT) { // 秒标
            throw new BorrowException("发布失败，还款方式设置错误，秒标只能为一次性还款！", 1);
        } else if (getBorrowTimeType() == 0) { // 月标
            styleArr = new int[3];
            styleArr[0] = BorrowStyle.STYLE_INSTALLMENT_REPAYMENT;
            styleArr[1] = BorrowStyle.STYLE_ONETIME_REPAYMENT;
            styleArr[2] = BorrowStyle.STYLE_MONTHLY_INTEREST;
        } else if (getBorrowTimeType() == 1) { // 天标
            styleArr = new int[1];
            styleArr[0] = BorrowStyle.STYLE_ONETIME_REPAYMENT;
        }
        if (styleArr == null || !ArrayUtils.contains(styleArr, getStyle())) {
            throw new BorrowException("发布失败，还款方式设置错误！", 1);
        }
    }

    public void validBorrow() {
        if (StringUtil.isBlank(getContent())) {
            throw new BorrowException("借款描述不能为空！", 1);
        }
    }

    /**
     * 投标校验
     *
     * @param model
     * @param attestation
     */
    public void validBorrowStatus(BorrowModel model, UserIdentify attestation) {
        if (model.getStatus() != 1 && model.getStatus() != 19) { // 如果标的状态不等于初审通过或自动投标中的任何一个，则抛出异常
            throw new BorrowException("该标目前无法投标，投标失败！", 1);
        }

        if (model.getUser().getUserId() == attestation.getUserId()) {
            throw new BorrowException("您不能投自己发布的标，投标失败！ ", 1);
        }
        if (model.getAccountYes() >= model.getAccount()) {
            throw new BorrowException("此标已满，投标失败！", 1);
        }
    }

    /**
     * 投标前校验用户认证状态及用户类型
     *
     * @param userIdentify
     */
    public void checkUser(UserIdentify userIdentify, UserCache userCache) {
        if (userCache.getUserType() == UserType.BORROWER) {
            throw new BusinessException("借款账户不能投资!", UserException.TYPE_CLOSE);
        }
        if (userIdentify.getRealNameStatus() != 1) {
            throw new UserException("请先实名认证!", UserException.TYPE_CLOSE);
        }

        AutoTenderConfRuleCheck check = RuleCheckHelper.getValue(AutoTenderConfRuleCheck.class);
        if (check != null) {
            if (check.tender_valid.status == 1) {
                if (check.tender_valid.real_enable == 1 && userIdentify.getRealNameStatus() != 1) {
                    throw new BorrowException("您还未通过实名认证,投标失败!", UserException.TYPE_CLOSE);
                }
                if (check.tender_valid.phone_enable == 1 && userIdentify.getMobilePhoneStatus() != 1) {
                    throw new BorrowException("您还未通过手机认证,投标失败!", UserException.TYPE_CLOSE);
                }
            }
        }

    }

    /**
     * 投标前校验
     */
//	public Borrow checkTenderModel(Borrow borrow, User user) {
//
//		if (!getInPwd().equals(borrow.getPwd())) {
//			throw new BorrowException("定向标密码不正确!", BorrowException.TYPE_CLOSE);
//		}
//		return borrow;
//	}

    /**
     * 校验查看的标是否存在
     *
     * @param borrow Borrow
     */
    public void checkBorrowHide(Borrow borrow) {
        if (!((DateUtil.getTime(borrow.getAddTime()) * 1000) + "").equals(this
                .getStartTime())) {
            throw new BorrowException("当前借款标不存在，或链接错误，查看失败！");
        }
    }

    /**
     * 检查输入的数据是否符合系统规则
     */
    public void checkAward() {
        if (super.getAward() == 1) {
            if (super.getPartAccount() <= 0) {
                throw new BorrowException("请输入范围在0.1%到6%之间的奖励值！", 1);
            } else if (super.getPartAccount() < 0.1
                    || super.getPartAccount() > 6) {
                throw new BorrowException("请输入范围在0.1%到6%之间的奖励值！", 1);
            }
        } else if (super.getAward() == 2) {
            if (super.getFunds() <= 0) {
                throw new BorrowException("你输入的奖励有误，请重新输入！", 1);
            }
        }

    }
    
    /**
     * 验证定向标密码不能为空
     */
    public void validDXB() {
        if (this.isDXB == 1 && StringUtil.isBlank(getPwd())) {
            throw new BorrowException("你的定向标密码不能为空！", 1);
        }
    }

    /**
     * 校验交易密码
     *
     * @param user User
     */
    public void checkPayPwd(User user) {
        if (StringUtil.isBlank(this.payPwd)) {
            throw new BorrowException("请输入交易密码！", 1);
        }
        if (StringUtil.isBlank(user.getPayPwd())) {
            throw new BorrowException("请先设置交易密码！", 1);
        }
        if (!user.getPayPwd().equals(MD5.encode(this.payPwd))) {
            throw new BorrowException("请输入正确的交易密码！", 1);
        }
    }

    public void validUploadPic(File file) {
        if (file == null) {
            throw new UserException("你上传的图片为空！", 1);
        }
    }

    public void validCancelBorrow(Borrow borrow) {
        if (borrow == null || borrow.getStatus() != 1) {
            throw new BorrowException("该借款标状态不正确！", 1);
        }
    }

    public List<BorrowUpload> picList(String fileValueList) {
        List<BorrowUpload> list = new ArrayList<BorrowUpload>();
        BorrowUpload borrowUpload = null;
        String[] str = fileValueList.split(",");
        for (int i = 0; i < str.length; i++) {
            if (StringUtil.isBlank(str[i])) {
                continue;
            }
            borrowUpload = new BorrowUpload();
            borrowUpload.setPicPath("/data/upfiles/images/borrow/" + str[i]);
            borrowUpload.setType(4);
            list.add(borrowUpload);
        }
        return list;
    }

    /**
     * 获取标的类型
     *
     * @param type
     * @return
     */
    public int getBorrowType(String type) {
        if (type.equals("miaobiao")) { // 秒标
            return 101;
        } else if (type.equals("month")) {// 信用标
            return 102;
        } else if (type.equals("fast")) { // 抵押标
            return 103;
        } else if (type.equals("jin")) { // 净值标
            return 104;
        } else if (type.equals("flow")) {// 流转标
            return 110;
        } else if (type.equals("offvouch")) { // 担保标
            return 112;
        } else {
            return 102;
        }
    }

	/*
     * public String[] getFilePath(User user, String sep, File[] files) throws
	 * Exception { List<String> list = new ArrayList<String>(); for (int i = 0;
	 * i < files.length; i++) { String dataPath =
	 * ServletActionContext.getServletContext().getRealPath("/data"); String
	 * contextPath = ServletActionContext.getServletContext().getRealPath("/");
	 * Date d1 = DateUtil.getNow(); String upfiesDir = dataPath + sep + "upfiles" + sep
	 * + "images" + sep; String destfilename1 = upfiesDir +
	 * DateUtil.dateStr2(d1) + sep + user.getUserId() + "_borrow" + "_" +
	 * d1.getTime() + ".jpg"; String filePath = destfilename1; filePath =
	 * this.truncatUrl(filePath, contextPath, sep); File imageFile1 = new
	 * File(destfilename1); FileUtils.copyFile(files[i], imageFile1);
	 * list.add(filePath); } String[] strings = new
	 * String[list.size()];//这行是为了防止类型转换异常 return list.toArray(strings); }
	 */

    public String getFilePath(User user, String sep, File file)
            throws Exception {
        String filePath;
        String dataPath = ServletActionContext.getServletContext().getRealPath(
                "/")
                + sep + "data";
        // 临时解决linux下面路径不对问题
        if (!dataPath.startsWith(sep)) {
            dataPath = sep + dataPath;
        }
        String contextPath = ServletActionContext.getServletContext()
                .getRealPath("/");
        Date d1 = DateUtil.getNow();
        String upfiesDir = dataPath + sep + "upfiles" + sep + "images" + sep;
        String destfilename1 = upfiesDir + DateUtil.dateStr2(d1) + sep
                + user.getUserId() + "_borrow" + "_" + d1.getTime() + ".jpg";
        filePath = destfilename1;
        filePath = this.truncatUrl(filePath, contextPath, sep);
        File imageFile1 = new File(destfilename1);
        FileUtils.copyFile(file, imageFile1);
        return filePath.substring(1);
    }

    private String truncatUrl(String old, String truncat, String sep) {
        String url = "";
        url = old.replace(truncat, "");
        url = url.replace(sep, "/");
        return url;
    }


    /**
     * 计算收益
     *
     * @param style     还款方式
     * @param money     投标金额
     * @param apr       利率
     * @param isDay     是否天标
     * @param timeLimit 借款期限
     * @return 根据还款方式，返回不同的利息计算器
     */
    public static InterestCalculator doInterestCalculator(int style, double money, double apr, int isDay, int timeLimit) {
        InterestCalculator ic = null;
        Date date = DateUtil.getNow();
        if (isDay == 1 && style == BorrowStyle.STYLE_ONETIME_REPAYMENT) { // 天标,一次性还款
            ic = new OnetimeRepaymentCalculator(money, apr, date, 1, 0);
        } else if (style == BorrowStyle.STYLE_ONETIME_REPAYMENT) { // 一次性还款
            ic = new OnetimeRepaymentCalculator(money, apr, date, timeLimit, 0);
        } else if (style == BorrowStyle.STYLE_MONTHLY_INTEREST) { // 每月还息到期还本
            ic = new MonthlyInterestCalculator(money, apr, date, timeLimit, true, 0);
        } else if (style == BorrowStyle.STYLE_INSTALLMENT_REPAYMENT) { // 等额本息
            ic = new InstallmentRepaymentCalculator(money, apr, date, timeLimit, 0);
        }
        if (isDay == 1) {
            ic.calculator(timeLimit);
        } else {
            ic.calculator();
        }
        return ic;
    }


    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        this.money = money;
    }

    public String getPayPwd() {
        return payPwd;
    }

    public void setPayPwd(String payPwd) {
        this.payPwd = payPwd;
    }


    public String getMinRepaymentTime() {
        return minRepaymentTime;
    }

    public void setMinRepaymentTime(String minRepaymentTime) {
        this.minRepaymentTime = minRepaymentTime;
    }

    public long getRepaymentId() {
        return repaymentId;
    }

    public void setRepaymentId(long repaymentId) {
        this.repaymentId = repaymentId;
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public int getAprSearch() {
        return aprSearch;
    }

    public void setAprSearch(int aprSearch) {
        this.aprSearch = aprSearch;
    }

    public int getTimeSearch() {
        return timeSearch;
    }

    public void setTimeSearch(int timeSearch) {
        this.timeSearch = timeSearch;
    }

    public int getMoneySearch() {
        return moneySearch;
    }

    public void setMoneySearch(int moneySearch) {
        this.moneySearch = moneySearch;
    }

    public int getCreditSearch() {
        return creditSearch;
    }

    public void setCreditSearch(int creditSearch) {
        this.creditSearch = creditSearch;
    }

    public int getOrder() {
        return order;
    }

    public void setOrder(int order) {
        this.order = order;
    }

    public long getBorrowId() {
        return borrowId;
    }

    public void setBorrowId(long borrowId) {
        this.borrowId = borrowId;
    }

    public int getIsDXB() {
        return isDXB;
    }

    public void setIsDXB(int isDXB) {
        this.isDXB = isDXB;
    }

    public int getIsDS() {
        return isDS;
    }

    public void setIsDS(int isDS) {
        this.isDS = isDS;
    }

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        this.time = time;
    }

    public String getBidStatus() {
        return bidStatus;
    }

    public void setBidStatus(String bidStatus) {
        this.bidStatus = bidStatus;
    }

    public String getTenderBilNo() {
        return tenderBilNo;
    }

    public void setTenderBilNo(String tenderBilNo) {
        this.tenderBilNo = tenderBilNo;
    }

    public String getTenderBilDate() {
        return tenderBilDate;
    }

    public void setTenderBilDate(String tenderBilDate) {
        this.tenderBilDate = tenderBilDate;
    }

    public List<BorrowMortgage> getBorrowMortgageList() {
        return borrowMortgageList;
    }

    public void setBorrowMortgageList(List<BorrowMortgage> borrowMortgageList) {
        this.borrowMortgageList = borrowMortgageList;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public double getBorrowTotal() {
        return borrowTotal;
    }

    public void setBorrowTotal(double borrowTotal) {
        this.borrowTotal = borrowTotal;
    }

    public int getIsShowRegister() {
        return isShowRegister;
    }

    public void setIsShowRegister(int isShowRegister) {
        this.isShowRegister = isShowRegister;
    }

    public int getCurrPeriod() {
        return currPeriod;
    }

    public void setCurrPeriod(int currPeriod) {
        this.currPeriod = currPeriod;
    }

    public long getVouchFirmId() {
        return vouchFirmId;
    }

    public void setVouchFirmId(long vouchFirmId) {
        this.vouchFirmId = vouchFirmId;
    }

    public String getBorrowName() {
        return borrowName;
    }

    public void setBorrowName(String borrowName) {
        this.borrowName = borrowName;
    }

    public String getRedEnvelopeStr() {
        return redEnvelopeStr;
    }

    public void setRedEnvelopeStr(String redEnvelopeStr) {
        this.redEnvelopeStr = redEnvelopeStr;
    }

    public long[] getRedEnvelopeIds() {
        //将字符串截取以后强行转换为long类型数组
        try {
            redEnvelopeIds = (long[]) ConvertUtils.convert(getRedEnvelopeStr().split(","), long.class);

            return redEnvelopeIds;
        } catch (Exception e) {

            return null;
        }
    }

    public void setRedEnvelopeIds(long[] redEnvelopeIds) {
        this.redEnvelopeIds = redEnvelopeIds;
    }

    public String getSearchName() {
        return searchName;
    }

    public void setSearchName(String searchName) {
        this.searchName = searchName;
    }

    public int getPreStatus() {
        return preStatus;
    }

    public void setPreStatus(int preStatus) {
        this.preStatus = preStatus;
    }

    public boolean getIps() {
        return ips;
    }

    public void setIps(boolean ips) {
        this.ips = ips;
    }

    public Long[] getMyRIRCouponId() {
        return myRIRCouponId;
    }

    public void setMyRIRCouponId(Long[] myRIRCouponId) {
        this.myRIRCouponId = myRIRCouponId;
    }


    public long[] getExperiences() {
        return experiences;
    }

    public void setExperiences(long[] experiences) {
        this.experiences = experiences;
    }

    public double getTotalRedEnvelopeMoney() {
        return totalRedEnvelopeMoney;
    }

    public void setTotalRedEnvelopeMoney(double totalRedEnvelopeMoney) {
        this.totalRedEnvelopeMoney = totalRedEnvelopeMoney;
    }

    public double getTotalExperienceMoney() {
        return totalExperienceMoney;
    }

    public void setTotalExperienceMoney(double totalExperienceMoney) {
        this.totalExperienceMoney = totalExperienceMoney;
    }

    public byte getOpenExperience() {
        return openExperience;
    }

    public void setOpenExperience(byte openExperience) {
        this.openExperience = openExperience;
    }

    public double getMostExperience() {
        return mostExperience;
    }

    public void setMostExperience(double mostExperience) {
        this.mostExperience = mostExperience;
    }

    public double getMostExperienceSingle() {
        return mostExperienceSingle;
    }

    public void setMostExperienceSingle(double mostExperienceSingle) {
        this.mostExperienceSingle = mostExperienceSingle;
    }

    public long getRateInterestId() {
        return rateInterestId;
    }

    public void setRateInterestId(long rateInterestId) {
        this.rateInterestId = rateInterestId;
    }

    public String getInPwd() {
        return inPwd;
    }

    public void setInPwd(String inPwd) {
        this.inPwd = inPwd;
    }

    public String getTenderResultFlg() {
        return tenderResultFlg;
    }

    public void setTenderResultFlg(String tenderResultFlg) {
        this.tenderResultFlg = tenderResultFlg;
    }

    public String getTppUserCustId() {
        return tppUserCustId;
    }

    public void setTppUserCustId(String tppUserCustId) {
        this.tppUserCustId = tppUserCustId;
    }

    public Integer[] getCategorys() {
        return categorys;
    }

    public void setCategorys(Integer[] categorys) {
        this.categorys = categorys;
    }

    public Integer[] getTypes() {
        return types;
    }

    public void setTypes(Integer[] types) {
        this.types = types;
    }

    public Integer[] getStatuss() {
        return statuss;
    }

    public void setStatuss(Integer[] statuss) {
        this.statuss = statuss;
    }

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        this.param = param;
    }

	public byte getTenderType() {
		return tenderType;
	}

	public void setTenderType(byte tenderType) {
		this.tenderType = tenderType;
	}

    public String getTypeStr(){
        if(getType()==BorrowType.TYPE_OFFVOUCH){
            return "趣豆计划";
        }else if (getType() == BorrowType.DELIVER_GOODS){
            return "0元购";
        }else{
            return "其他";
        }
    }

    public String getStatusStr(){
        if(getStatus() == BorrowStatus.STATUS_USER_CANCEL){
            return "用户撤回";
        }else if (getStatus() == BorrowStatus.STATUS_PUBLISHING){
            return "待初审";
        }else if (getStatus() == BorrowStatus.STATUS_TRIAL_PASSED){
            return "初审通过";
        }else if (getStatus() == BorrowStatus.STATUS_TRIAL_PASSED && getAccountYes() == getAmount()){
            return "满标待审";
        }else if (getStatus() == BorrowStatus.STATUS_TRIAL_PASSLESS ){
            return "初审未通过";
        }else if (getStatus() == BorrowStatus.STATUS_RECHECK_PASS ){
            return "复审通过";
        }else if (getStatus() == BorrowStatus.STATUS_RECHECK_PASSLESS ||  getStatus() == BorrowStatus.STATUS_RECHECK_PASSLESS2){
            return "复审未通过";
        }else if (getStatus() == BorrowStatus.STATUS_MANAGER_CANCEL ||  getStatus() == BorrowStatus.STATUS_MANAGER_CANCEL2){
            return "管理员撤回";
        }else if (getStatus() == BorrowStatus.STATUS_REPAYMENT_START ){
            return "还款中";
        }else if (getStatus() == BorrowStatus.STATUS_REPAYMENT_DOING ){
            return "部分还款";
        }else if (getStatus() == BorrowStatus.STATUS_REPAYMENT_DONE ){
            return "还款成功";
        }else  {
            return getStatus()+"";
        }
    }

    public String getStyleStr(){
        if(getStyle() == BorrowStyle.STYLE_INSTALLMENT_REPAYMENT){
            return "按月分期还款";
        }else if (getStyle() == BorrowStyle.STYLE_ONETIME_REPAYMENT){
            return  "一次性还款";
        }else if(getStyle() == BorrowStyle.STYLE_MONTHLY_INTEREST){
            return "每月还息到期还本";
        }else {
            return getStyle()+"";
        }
    }

}
